package com.yc.jpyy.mobile.controller;

import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.BizDao;
import com.yc.jpyy.mobile.service.BizService;

@Controller
@RequestMapping(value = "/student")
public class GetAppointmentLearnTimeController extends BaseController {

	@Autowired
	private BizService bizService;

	@Autowired
	private BizDao bizDao;


	/**
	 * 获取预约课时
	 * 
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/getAppointmentLearnTime", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String getAppointmentLearnTime(HttpServletRequest request)
			throws UnsupportedEncodingException {

		RestResponse response = new RestResponse();

		try {
			// 用户Id
			String studentId = request.getParameter("studentId");
			if((null!=studentId&&!studentId.equals(""))){
				// 查询预约课时信息
				Map<String, Object> listData = bizService.getAppointmentLearnTimeByStuId(studentId);
				if(listData!=null&&listData.size()>0)
				{
					// 设置数据集合
					response.setData(listData);
				}
				else
				{
					response.setErrorcode(1);
					response.setMessage("无数据！");
				}
			}else{
				response.setErrorcode(1);
				response.setMessage("缺少必填字段！");
			}
		} catch (Exception e) {
			System.out.println("获取预约课时信息："+ e.toString());
			response.setErrorcode(1);
			response.setMessage("获取预约课时信息失败!");
		} finally {
			return response.toJSON();
		}

	}


}
